package com.fs.groupSeven.service.impl;

import com.fs.groupSeven.Dao.AttendanceDao;
import com.fs.groupSeven.pojo.Attendance;
import com.fs.groupSeven.pojo.Classroom;
import com.fs.groupSeven.service.AttendanceService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: fbb
 * @createDate: 2020/10/10 19:07
 */

@Service
public class AttendanceServiceImpl implements AttendanceService {
    private AttendanceDao attendanceDao;

    @Autowired
    public AttendanceServiceImpl(AttendanceDao attendanceDao) {
        this.attendanceDao = attendanceDao;
    }

    @Override
    public List<Attendance> queryAttendanceList() {
        return null;
    }

    @Override
    public PageInfo<Attendance> getAttendanceByPage(Integer currentPage, Integer pageSize) {
        Page<Object> objects = PageHelper.startPage(currentPage, pageSize);
        List<Attendance> attendances = attendanceDao.queryAttendanceList();
        for (Attendance attendance : attendances) {
            // System.out.println(attendance.getAddTime());
        }
        PageInfo<Attendance> attendancePageInfo = new PageInfo<>(attendances);
        return attendancePageInfo;
    }

    @Override
    public boolean addOneAttendance(Attendance attendance) {
        int insult = attendanceDao.addOneAttendance(attendance);
        return insult > 0;
    }

    @Override
    public List<Attendance> getAttendanceMessageLike(String attendanceMessage) {
        List<Attendance> attendances = attendanceDao.queryByAttendMessage(attendanceMessage);
        return attendances;
    }

    @Override
    public PageInfo<Attendance> getAttendanceKuKeByPage(Integer currentPage, Integer pageSize) {
        Page<Object> objects = PageHelper.startPage(currentPage, pageSize);
        List<Attendance> attendances = attendanceDao.queryAttendanceKuKeList();
        for (Attendance attendance : attendances) {
            // System.out.println(attendance.getAddTime());
        }
        PageInfo<Attendance> attendancePageInfo = new PageInfo<>(attendances);
        return attendancePageInfo;
    }
}
